package com.wyp168.leetcode;

/**
 * @ClassName IsPalindrome
 * @Description TODO
 * @Author wyp168
 * @Date 2022/8/4 09:30
 */
public class IsPalindrome {
    public static void main(String[] args) {
        int intVal = 121;
        Solution solution = new Solution();
        boolean palindrome = solution.isPalindrome(intVal);
        System.out.println(palindrome);
    }
}

class Solution {
    public boolean isPalindrome(int x) {
        if (x < 0) {
            return false;
        }
        int reverseX = 0;
        int temp = x;
        while (temp != 0) {
            reverseX = reverseX * 10 + temp%10;
            temp /= 10;
        }

        if (x == reverseX) {
            return true;
        }
        return false;
    }
}